<?
function is_email($email){
  if (function_exists("filter_var")){
    $s=filter_var($email, FILTER_VALIDATE_EMAIL);
    return !empty($s);
  }
  $p = '/^[a-z0-9!#$%&*+-=?^_`{|}~]+(\.[a-z0-9!#$%&*+-=?^_`{|}~]+)*';
  $p.= '@([-a-z0-9]+\.)+([a-z]{2,3}';
  $p.= '|info|arpa|aero|coop|name|museum|mobi)$/ix';
  return preg_match($p, $email);
};


$ErrorStr="";
foreach($arResult["ERROR"] as $error):
$ErrorStr.=$error;
endforeach;

$showdata=(count($arResult["ERROR"])>0);
foreach($arResult["ORDER_PROP"]["USER_PROPS_Y"] as $k => $field):
unset($arResult["ORDER_PROP"]["USER_PROPS_Y"][$k]["ERROR"]);
unset($arResult["ORDER_PROP"]["USER_PROPS_Y"][$k]["LASTVALUE"]);

if(strpos($ErrorStr,'"'.$field["NAME"].'"'))$arResult["ORDER_PROP"]["USER_PROPS_Y"][$k]["ERROR"]=true;
$arResult["ORDER_PROP"]["USER_PROPS_Y"][$k]["LASTVALUE"]=
    ($showdata && !$arResult["ORDER_PROP"]["USER_PROPS_Y"][$k]["ERROR"])?$field["VALUE_FORMATED"]:"";
endforeach;

$arResult["WRONG_EMAIL"]=(!is_email($arResult["ORDER_PROP"]["USER_PROPS_Y"]["1"]["VALUE"]) && 
                        !empty($arResult["ORDER_PROP"]["USER_PROPS_Y"]["1"]["VALUE"]) && 
                        !$arResult["ORDER_PROP"]["USER_PROPS_Y"]["1"]["ERROR"]);
                        
foreach($arResult["BASKET_ITEMS"] as $k => $arBasketItems):
$rs=CIBlockElement::GetList(array(),array("ID" =>$arBasketItems["PRODUCT_ID"]), false, array(), 
array("ID","IBLOCK_ID","NAME","DETAIL_PAGE_URL","PROPERTY_CML2_LINK")); 

while($ar=$rs->GetNextElement())
{
$Fields=$ar->fields;


$subres= CIBlockElement::GetList(Array(), 
    Array("ID"=>$Fields["PROPERTY_CML2_LINK_VALUE"]), 
    false, Array("nPageSize"=>50), 
    Array("ID", "NAME","PREVIEW_PICTURE","DETAIL_PAGE_URL"));    
    
if($nob=$subres->GetNextElement())$subarFields=$nob->GetFields();
$arResult["BASKET_ITEMS"][$k]["DETAIL_PAGE_URL"]=$subarFields["DETAIL_PAGE_URL"];

//$arResult["BASKET_ITEMS"][$k]["DETAIL_PAGE_URL"]="/".$Fields["IBLOCK_TYPE_ID"]."/".$Fields["IBLOCK_CODE"]."/".$Fields["CODE"]."/";
}



endforeach;
?>